package com.example.recordlifeapplication;

import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;

import androidx.appcompat.app.AppCompatActivity;

public class Exit extends AppCompatActivity {
    public boolean onCreateOptionsMenu(Menu menu)
    {
        MenuInflater mf = new MenuInflater(this);
        mf.inflate(R.menu.menu_main,menu); //这里的R.menu.menu为XML文件的ID
        return super.onCreateOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item)
    {
        if(item.getItemId() == R.id.exit) finish();
        return super.onOptionsItemSelected(item);
    }
}
